package com.bs.manager04.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bs.manager04.entity.Menu;
import com.bs.manager04.mapper.MenuMapper;
import com.bs.manager04.service.IMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单管理表 服务实现类
 * </p>
 *
 * @author yao
 * @since 2022-12-17
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Resource
    MenuMapper mapper;

    @Override
    public Page<Menu> getIndex(Integer pageNum, Integer pageSize, String name) {
       Page<Menu> menuPage=new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<Menu> lq=new LambdaQueryWrapper<>();
        lq.like(StringUtils.isNotBlank(name),Menu::getMenuname,name);
        menuPage=mapper.selectPage(menuPage,lq);
        return menuPage;
    }

    @Override
    public List<Menu> getByMenuPid(String pid) {
        return mapper.getByMenuPid(pid);
    }

    @Override
    public List<Menu> addMenus(String userid, String pid) {
        return mapper.addMenus(userid, pid);
    }

    @Override
    public List<String> addPremission(String userid) {
        return mapper.addPremission(userid);
    }
}
